const install = (Vue,vm)=>{
	const check = async ()=>{
		let LoginUser = uni.getStorageSync('LoginUser')?uni.getStorageSync('LoginUser'):{};
		if(Object.values(LoginUser)<=0){
			uni,uni.showToast({
				title: '请先登录',
				duration:0,
				complete:function(res){
					uni.switchTab({
							url:'/pages/admin/index'
					});
				}
			});
			return false;
		}else{
				let result = await vm.$u.api.admin.check({
					id:LoginUser.id?LoginUser.id:0,
					username:LoginUser.username?LoginUser.username:''
				})
				if(result.code == 1){
					uni.setStorageSync('LoginUser',result.data);
					return true;
				}else{
					uni.removeStorageSync('LoginUser');
					uni.showToast({
						title:'非法登录',
						duration:0,
						complete:function(res){
							uni.switchTab({
								url:'/pages/admin/index'
							});
						}
					});
					return false;
				}
		}
	}
	vm.$u.auth={
		check
	}
}
export default{
	install
};